/**
 * http://usejsdoc.org/
 */
global.BASE_DIR = __dirname,
global.APP = BASE_DIR + '/app/';
global.CON = APP + '/controller/',
global.CORE = APP + '/core/',
global.MODEL = APP + '/model/',
global.LOG = BASE_DIR + '/log/',
global.LIB = BASE_DIR + '/node_modules/',
global.CONF = BASE_DIR + '/conf/',
global.STATIC = BASE_DIR + '/public/',
global.VIEW = BASE_DIR + '/view/';

/***
 * modules 引入
 */
global.lib = {
	http : require('http'),
	fs : require('fs'),
	url : require('url'),
	querystring : require('querystring'),
	httpParam : require(LIB+'http_param'),
	staticModule : require(LIB+'static_module'),
	router : require(CORE+'router'),
	action : require(CORE+'action'),
	jade : require('jade'),
	socket : require('socket.io'),
	path : require('path'),
	//parseCookie : require('connect').utils.parseCookie,
	session : require(LIB+'node_session'),
	util : require('util')
};


global.app = lib.http.createServer(function(req, res) {
	res.render = function(){
		var template = arguments[0];
		var options = arguments[1];
		var str = lib.fs.readFileSync(template,'utf8');
		var fn = lib.jade.compile(str,{filename:template,pretty:true});
		
		var page = fn(options);
		res.writeHeader(200,{'Content-Type':'text/html'});
		res.end(page);
	};
	req.setEncoding('UTF-8');
	lib.router.router(res, req);
}).listen(8080);

console.log("Sever Starting...");